Skip to content

Editor: Tab inserts 4 spaces (no TabError) - #13

Merged
cedricvogel-leo merged 1 commit into
mainfrom
fix/editor-soft-tabs
Oct 25, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
fix/editor-soft-tabs

Conversation

@cedricvogel-leo

Copy link
Copy Markdown
Collaborator

LiaScript's code editor defaults to tabSize 2 and useSoftTabs false (src/elm/Lia/Markdown/Code/View.elm: Editor.tabSize (int "data-tabsize" 2), Editor.useSoftTabs False). So Tab inserts a real tab character, and in a block indented with 4 spaces Python stops with TabError: inconsistent use of tabs and spaces in indentation.

Change. attach() sets tabSize = 4 and useSoftTabs = true on each lia-editor of the block, through the element's own setters (src/typescript/webcomponents/editor.ts), which pass them on to Ace.

  • attach() runs on every DOM change, so when LiaScript recreates the editors (e.g. a slide shown again), the new editors get the setting again. Elm only re-sets these properties when its own value changes, so it doesn't undo them on a re-render.
  • A block's own data-tabsize, or a tabSize/useSoftTabs in its data-ace-options (LiaScript puts both on the lia-editor as attributes), still wins.
  • An editor that isn't upgraded to LiaScript's element yet is left for the next attach(). Setting the property before the upgrade would hide the setter.
  • The README has a short note for course authors.

Test (hosted LiaScript player, this branch's macro vs main's, headless Chrome). In a block indented with 4 spaces: Enter after total = 0, clear the auto-indent, press Tab, type a statement, then ▶ Run.

the new line Run
main " \ttotal = total + 0" TabError: inconsistent use of tabs and spaces in indentation
this branch " total = total + 0" 6
  • A block with <!-- data-tabsize="8" data-ace-options="useSoftTabs=false" --> keeps tab size 8 and hard tabs.
  • After going to the next slide and back (the editors are recreated), the first editor again has tab size 4 and soft tabs, both on the element and in Ace's own options.
  • node scripts/check-macro.mjs passes.

🤖 Generated with Claude Code

…rror

LiaScript's code editor defaults to tabSize 2 and useSoftTabs false
(Code/View.elm), so Tab inserts a real tab character and a block indented
with 4 spaces stops with "TabError: inconsistent use of tabs and spaces".
attach() now sets tabSize 4 and soft tabs on each of the block's
lia-editor elements, on every re-render (LiaScript recreates them when a
slide is shown again). A block's own data-tabsize or data-ace-options
still wins, and an editor not yet upgraded is left for the next attach().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit 2a0e598 into main Oct 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant